package com.qd.panda.dc.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

/**
 * @author sjk
 */
@Data
@Accessors(chain = true)
@ToString
public class CarInOutDTO {
    /**
     * 停⻋场唯⼀编号
     */
    private String parkingId;
    /**
     * 车牌号
     */
    private String plateNumber;
    /**
     * 进
     */
    private List<In> in;
    /**
     * 出
     */
    private List<Out> out;

    public void freeData() {
        this.parkingId = null;
        this.plateNumber = null;
        Optional.ofNullable(in).ifPresent(List::clear);
        Optional.ofNullable(out).ifPresent(List::clear);
    }

    @Data
    @EqualsAndHashCode(callSuper = false)
    @Accessors(chain = true)
    @ToString
    public static class In extends Base {
        /**
         * 进场时间
         */
        private String inTime;

        private String payUrl;

        @Override
        public void freeData() {
            this.inTime = null;
            this.payUrl = null;
            super.freeData();
        }

    }

    @Data
    @EqualsAndHashCode(callSuper = false)
    @Accessors(chain = true)
    @ToString
    public static class Out extends Base {
        private String outTime;

        private BigDecimal parkingAmount;

        private String parkingOutId;

        private Integer stayedTime;

        @Override
        public void freeData() {
            this.outTime = null;
            this.parkingAmount = null;
            this.parkingOutId = null;
            this.stayedTime = null;
            super.freeData();
        }
    }

    @Data
    @Accessors(chain = true)
    static class Base {
        private String carType;
        /**
         * 进场通道名称
         */
        private String channelName;
        /**
         * 进场通道编号
         */
        private String channelNo;
        /**
         * 创建时间
         */
        private String createdAt;

        private String garageName;

        private String garageNo;

        private Integer id;
        /**
         * 进场图⽚地址
         */
        private String imageUrl;
        /**
         * 进出场唯⼀编号
         */
        private String inOutId;
        /**
         * 停⻋场唯⼀编号
         */
        private String parkingInId;
        private String tokenValue;
        private String tradeId;
        private String updatedAt;

        public void freeData() {
            this.carType = null;
            this.channelName = null;
            this.channelNo = null;
            this.createdAt = null;
            this.garageName = null;
            this.garageNo = null;
            this.id = null;
            this.imageUrl = null;
            this.inOutId = null;
            this.parkingInId = null;
            this.tokenValue = null;
            this.tradeId = null;
            this.updatedAt = null;
        }
    }
}






